<?php
check_login();

header("Content-type:text/html;charset=utf-8");
require(ROOT_PATH."lib/cls_upload.php");
$up= new upload();
if($_GET['xh'])
{
	$up->uploaddir='upfile/images/';
	$up->userdir='upfile/images/';
	$data=$up->uploadfile('filedata');
	echo "{'err':'".($data['err']?jsonString($data['err']):'')."','msg':'".jsonString($data['filename'])."'}";
}else
{
	if($_POST["maxsize"]) {
		$up->maxsize = $_POST["maxsize"] * 1024;
	}
	$up->uploaddir='upfile/images/';
	$up->userdir='upfile/images/';
	$data=$up->uploadfile('upfile');
	if($data['err'])
	{
		echo "<script>alert('".$data['err']."');history.go(-1);</script>";
	}else
	{
		if($_POST["fun"]) {
			echo "<script>window.opener.".$_POST['fun']."('".$data['filename']."');</script>";
			echo "<script>window.close();</script>";
		} else if ($_POST["id"]) {
			echo "<script>window.opener.document.getElementById('".$_POST['id']."').value='".$data['filename']."'</script>";
			echo "<script>alert('上传成功');window.close();</script>";
		} else{
			echo "<script>window.opener.document.".$_POST['formname'].".".$_POST['editname'].".value='".$data['filename']."'</script>";
			echo "<script>alert('上传成功');window.close();</script>";
		}
	}
}





?>